package com.hgw.Demo09_StrategyPattern.examples;

/**
 * Data time:2021/12/20 20:42
 * StudentID:2019112118
 * Author:hgw
 * Description: 电影票类，充当环境类
 */
public class MovieTicket {
    private double price;
    private Discount discount;  // 维持一个对抽象折扣类的引用

    public void setPrice(double price) {
        this.price = price;
    }

    public void setDiscount(Discount discount) {
        this.discount = discount;
    }

    public double getPrice() {
        // 调用折扣类的折扣价计算方法
        return discount.calculate(this.price);
    }
}
